<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="skladiscenje.*"%>
<%@ page import="java.util.ArrayList"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>SKLADISCENJE systems</title>
        <LINK href="CSS/style.css" rel="stylesheet" type="text/css" />
        <LINK href="CSS/menu.css" rel="stylesheet" type="text/css" />
        <LINK REL="SHORTCUT ICON" HREF="images/favicon.ico" />
    </head>
        
    <body>
		<table id="wrapper">
			<tr>
				<td>
					<% 
					if (session.getAttribute("uporabnik") != null) {
						Uporabnik uporabnik = (Uporabnik) session.getAttribute("uporabnik");
					%>
                	<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td>
                        		<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  	<tr>
                                    	<td class="head_top"></td>
                                  	</tr>
                                  	<tr>
                                    	<td>
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                               	  	<td class="head_middle"></td>
                                                	<td class="logout_bg"><%= uporabnik.getUporabniskoIme() %></td>
                                                	<td class="logout_logo"><a href="odjava.jsp"><img src="images/logout_logo.png" alt="logout" width="34" height="28" border="0"></a></td>
                                                	<td class="logout_right"></td>
                                             	</tr>
                                            </table>
                                        </td>
                                 	</tr>
                                  	<tr>
                                  	  	<td class="head_bottom"></td>
                                  	</tr>
                                  	<tr>
                                    	<td>
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                               	  	<td class="menu_left"></td>
                                                	<td class="menu_bg"><%@ include file="meni.jsp" %></td>
                                                	<td class="menu_right"></td>
                                             	</tr>
                                            </table>
                                        </td>
                                  	</tr>
                                  	<tr>
                                    	<td class="menu_bottom"></td>
                                  	</tr>
                                </table>
							</td>
                      	</tr>
                      	<tr>
                        	<td>
                            	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  	<tr>
                                      	<td class="left"></td>
                                      	<td valign="top" bgcolor="#E7F6FF">
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                                	<td>
                                                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                          	<tr>
                                                           	  	<td class="main_left"></td>
                                                            	<td bgcolor="#FFFFFF">
                                                            		<table class="izpisTabela" width="100%" cellspacing="0">
                                                            			<tr><td class="naslov" colspan="7">- PREGLED BLAGA -</td></tr>
                                                            			<tr>
                                                            				<th>ID</th>
                                                            				<th>Ime</th>
                                                            				<th>Tip</th>
                                                            				<th>Količina</th>
                                                            				<th>Enota</th>
                                                            				<th>Sektor</th>
                                                            				<th>Dovoljena količina</th>
                                                            			</tr>
                                                            			<%
                                                            			ArrayList<Blago> seznamBlaga;
                                                            			
                                                            			if(uporabnik.getSektor() == 0)
                                                            				seznamBlaga = Evidenca.izpisiVsoBlago();
                                                            			else
                                                            				seznamBlaga = Evidenca.izpisiVsoBlagoBySektor(uporabnik.getSektor());
                                                            			
                                                            			if(seznamBlaga.size() < 1){
                                                            				%>
                                                            				<tr><td colspan="7">Skladišče je trenutno prazno!</td></tr>
                                                            				<%
                                                            			}else{
                                                            				int tabela;
                                                            				for(int i = 0; i < seznamBlaga.size(); i++){
                                                            					if(i%2 == 0)
                                                            						tabela = 2;
                                                            					else
                                                            						tabela = 1;
                                                            					%>
                                                            					<tr class="izpisTabela<%= tabela %>">
		                                                            				<td><%= seznamBlaga.get(i).getID() %></td>
		                                                            				<td><%= seznamBlaga.get(i).getIme() %></td>
		                                                            				<td><%= seznamBlaga.get(i).getImeTip() %></td>
		                                                            				<td><%= seznamBlaga.get(i).getKolicina() %></td>
		                                                            				<td><%= seznamBlaga.get(i).getImeEnota() %></td>
		                                                            				<td><%= seznamBlaga.get(i).getSektor() %></td>
		                                                            				<td><%= seznamBlaga.get(i).getDovoljenaKolicina() %></td>
		                                                            			</tr>
                                                            					<%
                                                            				}
                                                            			}
                                                            			%>
                                                            		</table>
																</td>
                                                            	<td class="main_right"></td>
                                                          	</tr>
                                                        </table>
                                                    </td>
                                              	</tr>
                                              	<tr>
                                                	<td class="main_bottom"></td>
                                              	</tr>
                                            </table>
                                        </td>
                                        <td width="184" valign="top" bgcolor="#E7F6FF">
                                        	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                              	<tr>
                                                	<td>
                                                    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                          	<tr>
                                                           	  	<td class="side_left"></td>
                                                            	<td bgcolor="#FFFFFF"><%@ include file="statistika.jsp" %></td>
                                                            	<td class="side_right"></td>
                                                          	</tr>
                                                        </table>
                                                    </td>
                                              	</tr>
                                              	<tr>
                                                	<td class="side_bottom"></td>
                                              	</tr>
                                            </table>
                                        </td>
                                        <td class="right"></td>
                                  	</tr>
                                </table>
                            </td>
                      	</tr>
                      	<tr>
                        	<td class="footer"></td>
                      	</tr>
                    </table>
                    <%}else{response.sendRedirect("index.jsp?prijava=potrebna");}%>
                </td>
			</tr>
		</table>
	</body>
</html>
